package com.fingard.dsp.bank.reqrespobj.contract.detail;

import com.fingard.dsp.bank.reqrespobj.contract.ReqContract;
import com.fingard.text.StringHelper;
import com.fingard.xml.XmlTextWriter;

import java.util.HashMap;

public class RetAtsContractDetail {
	public String respCode;
    public String respInfo;
    public String reqSeqID;
    
    /** 签约统一信息码 */
    public String unifiedCode;
    
    /**原始信息码*/
    public String infoCode;
    
    /** 短信签约码 */
    public String token;
    
    /** 签约状态 */
    public String signState;

    /** 签约信息 */
    public String signMsg;
    
    /** 签约协议号 */
    public String authCode;
    
    /** 签约账号 */
    public String payAct;
    
    /** 签约户名 */
    public String payName;
    
    /** 卡折标志(1-存折,2-借记卡,3-贷记卡,4-准贷记卡) */
    public String cardType;
    
    /** 证件类型 */
    public String certType;
    
    /** 证件号码 */
    public String certNum;
    
    /** 预留手机号 */
    public String cellPhone;
    
    /** 法人姓名 */
    public String legalName;
    
    /** 法人证件类型 */
    public String legalCertType;
    
    /** 法人证件号码 */
    public String legalCertNum;
    
    /** 合约到期日(格式:yyyyMMdd) */
	public String deadLine;
	
	/** 签约后单笔代扣最大限额 */
	public String singleLimit;
	
	/** 单笔代扣周期限制单位(1-日,2-月,3-年) */
	public String periodLimit;
	
	/** 签约单笔代扣最大代扣次数(范围:1-9999) */
	public String countLimit;
	
	/** 授权号 */
	public String authId;
	/** 授权号 */
	public String signUrl;
	/** 确认标志 */
	public String step;
	/** 签约协议号 */
	public String newAuthCode;
	/** 签约签约确认方式 
0无需签约
1实时返回
2短信验证码
3短信回复（异步通知）即上行短信
4跳转
5批量授权 */
	public String signConfirmType;
	
    public String reqReserved1;
    public String reqReserved2;

	public RetAtsContractDetail() {
	}

    public RetAtsContractDetail(ReqContract p_req) {
        reqSeqID = p_req.contractDetail.askNumber;
    }
    
    public void writeToXml(XmlTextWriter retXmlWriter) throws Exception{
    	retXmlWriter.writeStartElement("DetailRecord");
    	
		retXmlWriter.writeElementString("RespCode", respCode);
		retXmlWriter.writeElementString("RespInfo", respInfo);
		retXmlWriter.writeElementString("ReqSeqID", reqSeqID);
		
		if (StringHelper.hasAnyChar(unifiedCode)) {
			retXmlWriter.writeElementString("UnifiedCode", unifiedCode);
		}
		if (StringHelper.hasAnyChar(infoCode)) {
			retXmlWriter.writeElementString("InfoCode", infoCode);
		}
		
		if (StringHelper.hasAnyChar(signState)) {
			retXmlWriter.writeElementString("SignState", signState);
		}
		if(StringHelper.hasAnyChar(token)) {
			retXmlWriter.writeElementString("Token", token);
		}
		if (StringHelper.hasAnyChar(authCode)) {
			retXmlWriter.writeElementString("AuthCode", authCode);
		}
		if (StringHelper.hasAnyChar(payAct)) {
			retXmlWriter.writeElementString("PayAct", payAct);
		}
		if (StringHelper.hasAnyChar(payName)) {
			retXmlWriter.writeElementString("PayName", payName);
		}
		if (StringHelper.hasAnyChar(cardType)) {
			retXmlWriter.writeElementString("CardType", cardType);
		}
		if (StringHelper.hasAnyChar(certType)) {
			retXmlWriter.writeElementString("CertType", certType);
		}
		if (StringHelper.hasAnyChar(certNum)) {
			retXmlWriter.writeElementString("CertNum", certNum);
		}
		if (StringHelper.hasAnyChar(cellPhone)) {
			retXmlWriter.writeElementString("CellPhone", cellPhone);
		}
		if (StringHelper.hasAnyChar(legalName)) {
			retXmlWriter.writeElementString("LegalName", legalName);
		}
		if (StringHelper.hasAnyChar(legalCertType)) {
			retXmlWriter.writeElementString("LegalCertType", legalCertType);
		}
		if (StringHelper.hasAnyChar(legalCertNum)) {
			retXmlWriter.writeElementString("LegalCertNum", legalCertNum);
		}
		if (StringHelper.hasAnyChar(deadLine)) {
			retXmlWriter.writeElementString("DealLine", deadLine);
		}
		if (StringHelper.hasAnyChar(singleLimit)) {
			retXmlWriter.writeElementString("SingleLimit", singleLimit);
		}
		if (StringHelper.hasAnyChar(periodLimit)) {
			retXmlWriter.writeElementString("PeriodLimit", periodLimit);
		}
		if (StringHelper.hasAnyChar(countLimit)) {
			retXmlWriter.writeElementString("CountLimt", countLimit);
		}
		if (StringHelper.hasAnyChar(newAuthCode)) {
			retXmlWriter.writeElementString("NewAuthCode", newAuthCode);
		}
		if (StringHelper.hasAnyChar(signConfirmType)) {
			retXmlWriter.writeElementString("SignConfirmType", signConfirmType);
		}
		if (StringHelper.hasAnyChar(signUrl)) {
			retXmlWriter.writeElementString("SignUrl", signUrl);
		}
		if (StringHelper.hasAnyChar(step)) {
			retXmlWriter.writeElementString("Step", step);
		}
		if (StringHelper.hasAnyChar(reqReserved1)) {
			retXmlWriter.writeElementString("ReqReserved1", reqReserved1);
		}
		if (StringHelper.hasAnyChar(reqReserved2)) {
			retXmlWriter.writeElementString("ReqReserved2", reqReserved2);
		}
        if (StringHelper.hasAnyChar(signMsg)) {
            retXmlWriter.writeElementString("SignMsg", signMsg);
        }
    }
    
    public HashMap<String,String> writeToHash(){
    	HashMap<String,String> retHash = new HashMap<String,String>();
    	
    	retHash.put("RespCode", respCode);
    	retHash.put("RespInfo", respInfo);
    	retHash.put("RdSeq", reqSeqID);
    	
    	if (StringHelper.hasAnyChar(signState)) {
    		retHash.put("SignState", signState);
		}
    	
    	if (StringHelper.hasAnyChar(unifiedCode)) {
    		retHash.put("UnifiedCode", unifiedCode);
		}
    	
    	if (StringHelper.hasAnyChar(infoCode)) {
    		retHash.put("InfoCode", infoCode);
		}
    	
		if(StringHelper.hasAnyChar(token)) {
			retHash.put("Token", token);
		}
		if (StringHelper.hasAnyChar(authCode)) {
			retHash.put("AuthCode", authCode);
		}
		if (StringHelper.hasAnyChar(payAct)) {
			retHash.put("PayAct", payAct);
		}
		if (StringHelper.hasAnyChar(payName)) {
			retHash.put("PayName", payName);
		}
		if (StringHelper.hasAnyChar(cardType)) {
			retHash.put("CardType", cardType);
		}
		if (StringHelper.hasAnyChar(certType)) {
			retHash.put("CertType", certType);
		}
		if (StringHelper.hasAnyChar(certNum)) {
			retHash.put("CertNum", certNum);
		}
		if (StringHelper.hasAnyChar(cellPhone)) {
			retHash.put("CellPhone", cellPhone);
		}
		if (StringHelper.hasAnyChar(legalName)) {
			retHash.put("LegalName", legalName);
		}
		if (StringHelper.hasAnyChar(legalCertType)) {
			retHash.put("LegalCertType", legalCertType);
		}
		if (StringHelper.hasAnyChar(legalCertNum)) {
			retHash.put("LegalCertNum", legalCertNum);
		}
		if (StringHelper.hasAnyChar(deadLine)) {
			retHash.put("DealLine", deadLine);
		}
		if (StringHelper.hasAnyChar(singleLimit)) {
			retHash.put("SingleLimit", singleLimit);
		}
		if (StringHelper.hasAnyChar(periodLimit)) {
			retHash.put("PeriodLimit", periodLimit);
		}
		if (StringHelper.hasAnyChar(countLimit)) {
			retHash.put("CountLimt", countLimit);
		}
		if (StringHelper.hasAnyChar(reqReserved1)) {
			retHash.put("ReqReserved1", reqReserved1);
		}
		if (StringHelper.hasAnyChar(reqReserved2)) {
			retHash.put("ReqReserved2", reqReserved2);
		}
		if (StringHelper.hasAnyChar(authId)) {
			retHash.put("AuthId", authId);
		}
		if (StringHelper.hasAnyChar(signUrl)) {
			retHash.put("SignUrl", signUrl);
		}
		if (StringHelper.hasAnyChar(step)) {
			retHash.put("Step", step);
		}
		if (StringHelper.hasAnyChar(signConfirmType)) {
			retHash.put("SignConfirmType", signConfirmType);
		}
		if (StringHelper.hasAnyChar(newAuthCode)) {
			retHash.put("NewAuthCode", newAuthCode);
		}
    	return retHash;
    }
}
